package com.ruoyi.web.controller.system.loginimg;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysLoginImg;
import com.ruoyi.system.service.ISysLoginImgService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 登陆轮播图Controller
 * 
 * @author chenjiuchang
 * @date 2024-04-17
 */
@RestController
@RequestMapping("/system/loginimg")
public class SysLoginImgController extends BaseController
{
    @Autowired
    private ISysLoginImgService sysLoginImgService;

    /**
     * 查询登陆轮播图列表
     */
    @Anonymous
//    @PreAuthorize("@ss.hasPermi('system:loginimg:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysLoginImg sysLoginImg)
    {
        startPage();
        List<SysLoginImg> list = sysLoginImgService.selectSysLoginImgList(sysLoginImg);
        return getDataTable(list);
    }

    /**
     * 导出登陆轮播图列表
     */
    @PreAuthorize("@ss.hasPermi('system:loginimg:export')")
    @Log(title = "登陆轮播图", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysLoginImg sysLoginImg)
    {
        List<SysLoginImg> list = sysLoginImgService.selectSysLoginImgList(sysLoginImg);
        ExcelUtil<SysLoginImg> util = new ExcelUtil<SysLoginImg>(SysLoginImg.class);
        util.exportExcel(response, list, "登陆轮播图数据");
    }

    /**
     * 获取登陆轮播图详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:loginimg:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysLoginImgService.selectSysLoginImgById(id));
    }

    /**
     * 新增登陆轮播图
     */
    @PreAuthorize("@ss.hasPermi('system:loginimg:add')")
    @Log(title = "登陆轮播图", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysLoginImg sysLoginImg)
    {
        return toAjax(sysLoginImgService.insertSysLoginImg(sysLoginImg));
    }

    /**
     * 修改登陆轮播图
     */
    @PreAuthorize("@ss.hasPermi('system:loginimg:edit')")
    @Log(title = "登陆轮播图", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysLoginImg sysLoginImg)
    {
        return toAjax(sysLoginImgService.updateSysLoginImg(sysLoginImg));
    }

    /**
     * 删除登陆轮播图
     */
    @PreAuthorize("@ss.hasPermi('system:loginimg:remove')")
    @Log(title = "登陆轮播图", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysLoginImgService.deleteSysLoginImgByIds(ids));
    }
}
